//
//  YSY_Game_NewsViewController.m
//  GoodManNews
//
//  Created by dllo on 16/1/11.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "YSY_Game_NewsViewController.h"
#import "Masonry.h"
@interface YSY_Game_NewsViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, retain) UITableView *newsTableView;
@property (nonatomic, retain) NSMutableArray *newsArr;
@end

@implementation YSY_Game_NewsViewController

- (void)dealloc
{
    self.newsTableView.delegate = nil;
    self.newsTableView.dataSource = nil;
    
    [_newsArr release];
    [_newsTableView release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self createView];
}

#pragma mark - 私有方法
- (void)createView {
    [self createTabelView];
    
}
- (void)createTabelView {
    self.newsTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];

    [self.view addSubview:self.newsTableView];
    [self.newsTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    self.newsTableView.delegate = self;
    self.newsTableView.dataSource = self;
    [self.newsTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
}

#pragma  mark - UITableView协议方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (self.newsArr) {
        return self.newsArr.count;
    }else {
        return 10;
    }
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.backgroundColor = [UIColor orangeColor];
    return cell;
    
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *headerView = [UIView new];
    headerView.backgroundColor = [UIColor cyanColor];
    headerView.frame = self.newsTableView.tableHeaderView.bounds;
//    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(self.newsTableView.tableHeaderView);
//    }];
    return headerView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return self.view.bounds.size.height / 3.0;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
